package controllers

import (
	"com.opennews.openplatform/web_api/services"
	"com.opennews.openplatform/web_api/shared"
	"github.com/gin-gonic/gin"
)

// Sets routes for user resource.
func SetProductRoutes(routerGroup *gin.RouterGroup) {
	controller := NewProductController()

	routerGroup.GET("/", controller.List)
}

type ProductController interface {
	List(ctx *gin.Context)
}

// Returns the instance of private member, userController, which implements UserController interface.
func NewProductController() ProductController {
	return productController{
		productService: services.NewProductService(),
	}
}

// Matches / of http get action.
func (this productController) List(ctx *gin.Context) {
	//this.userService = services.NewUserService()
	//users := this.userService.List()
	//
	//// Responses with specified http status code and json format result.
	//SendDataResponse(ctx, users)

	//result := this.productService.List()

	result := shared.MapData{
		"name": "Product",
	}

	SendDataResponse(ctx, result)
}

type productController struct {
	productService services.ProductService
}